<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>论坛列表</title>
    <link rel="stylesheet" href="${request.contextPath}/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${request.contextPath}/layFly/css/global.css">
</head>
<style>
</style>
<body>
<div class="layui-hide-xs">
    <div class="fly-panel fly-column">
        <div class="layui-container">
            <ul class="layui-clear">
<#--                <li class="layui-hide-xs"><a href="/">首页</a></li>-->
<#--                <li class="layui-this"><a href="">提问</a></li>-->
<#--                <li><a href="">分享<span class="layui-badge-dot"></span></a></li>-->
<#--                <li><a href="">讨论</a></li>-->
<#--                <li><a href="">建议</a></li>-->
<#--                <li><a href="">公告</a></li>-->
<#--                <li><a href="">动态</a></li>-->
<#--                <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><span class="fly-mid"></span></li>-->

                <!-- 用户登入后显示 -->
                <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="${request.contextPath}/to/forum?userId=${(user.id)!}">我发表的贴</a></li>
<#--                <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="../user/index.html#collection">我收藏的贴</a></li>-->
            </ul>

            <div class="fly-column-right layui-hide-xs">
<#--                <span class="fly-search"><i class="layui-icon"></i></span>-->
                <a href="${request.contextPath}/toAddForum" class="layui-btn">发表新帖</a>
            </div>
            <div class="layui-hide-sm layui-show-xs-block" style="margin-top: -10px; padding-bottom: 10px; text-align: center;">
                <a href="add.html" class="layui-btn">发表新帖</a>
            </div>
        </div>
    </div>
</div>
<div class="layui-container">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="fly-panel" style="margin-bottom: 0;">

                <div class="fly-panel-title fly-filter">
                    <a href="javascript:void(0)" class="layui-this">全部</a>
                    <span class="fly-mid"></span>
                    <a href="javascript:void(0)" class="layui-this">我的</a>
                    <div style="float: right">
                        <a href="" class="layui-this">按最新</a>
                        <span class="fly-mid"></span>
                        <a href="">按热议</a>
                    </div>

                </div>

                <ul class="fly-list" id="list">


                </ul>
            </div>
        </div>

    </div>
</div>

<div class="fly-footer">
    <p>NMN社区 2021 &copy; </p>
</div>

<script src="${request.contextPath}/layuiadmin/layui/layui.js"></script>
<script>
    layui.use(['jquery','form'],function () {
        var $ = layui.$
        var form =layui.form
        //获取帖子列表

            $.ajax({
                type:"post",
                url: "${request.contextPath}/forum/getAll",
                //这里没有用json传值，所以contentType
                contentType:'application/json; charset=UTF-8',
                success: function(res) {
                    console.log('res',res)
                    var data=res.data;
                    var html=''
                    for (var i = 0; i <data.length ; i++) {
                        var item=data[i];
                        html=html+'<li>' +
                                        '<h2>' +
                                             '<a href="${request.contextPath}/toDetail?id='+item.id+'" target="_blank">'+item.title+'</a>'+
                                        '</h2>' +
                                        '<div class="fly-list-info">' +
                                            '<a href="javascript:void(0)" link>' +
                                                '<cite>'+item.name+'</cite>' +
                                            '</a>' +
                                            '<span>'+item.createtime+'</span>' +
                                            '<span class="fly-list-nums">' +
                                                '<i class="iconfont icon-pinglun1" title="回答"></i> '+item.count +
                                            '</span>' +
                                        '</div>' +
                                    '</li>'
                    }
                    $("#list").html(html)
                    form.render()
                },
                error: function(res) {
                    layer.alert(res.msg,{icon:2})
                }
            })

        window.closeLayer=function(index){
            layer.close(index)
        }
    });

</script>

<script type="text/javascript">
    var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_30088308'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "w.cnzz.com/c.php%3Fid%3D30088308' type='text/javascript'%3E%3C/script%3E"));
</script>

</body>
</html>